package start.demo01.datatype.json.entity.editor.stringEditor;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import start.demo01.datatype.json.interfaces.StringEditor;

public class StringToJSON extends StringEditor {

    //$ strToJSON(m)
    public StringToJSON(String name, String cmd) {
        super(name,cmd);
    }

    @Override
    public void editor() {
        String org = (String) map.get(name);
        JSONObject jsonObject = JSONObject.parseObject(org);
        if (StringUtils.isEmpty(args))
            map.replace(name, jsonObject);
        else
            map.put(args,jsonObject);
    }
}
